home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / libcruft / ranlib / genchi.f < prev    next >
Text File  |  1996-07-19  |  1KB  |  46 lines

  1.       REAL FUNCTION genchi(df)
  2. C**********************************************************************
  3. C
  4. C     REAL FUNCTION GENCHI( DF )
  5. C                Generate random value of CHIsquare variable
  6. C
  7. C
  8. C                              Function
  9. C
  10. C
  11. C     Generates random deviate from the distribution of a chisquare
  12. C     with DF degrees of freedom random variable.
  13. C
  14. C
  15. C                              Arguments
  16. C
  17. C
  18. C     DF --> Degrees of freedom of the chisquare
  19. C            (Must be positive)
  20. C                         REAL DF
  21. C
  22. C
  23. C                              Method
  24. C
  25. C
  26. C     Uses relation between chisquare and gamma.
  27. C
  28. C**********************************************************************
  29. C     .. Scalar Arguments ..
  30.       REAL df
  31. C     ..
  32. C     .. External Functions ..
  33.       REAL gengam
  34.       EXTERNAL gengam
  35. C     ..
  36. C     .. Executable Statements ..
  37.       IF (.NOT. (df.LE.0.0)) GO TO 10
  38.       WRITE (*,*) 'DF <= 0 in GENCHI - ABORT'
  39.       WRITE (*,*) 'Value of DF: ',df
  40.       CALL XSTOPX ('DF <= 0 in GENCHI - ABORT')
  41.  
  42.    10 genchi = 2.0*gengam(1.0,df/2.0)
  43.       RETURN
  44.  
  45.       END
  46.